package com.siyu.preplan.planpplan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import com.siyu.preplan.planpplan.domain.PlanPPlan;
import com.siyu.preplan.planpplan.service.IPlanPPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 预案详情Controller
 *
 * @author hrhy
 * @date 2024-06-15
 */
@RestController
@RequestMapping("/preplan/plandplan")
public class PlanDPlanController extends BaseController
{
    @Autowired
    private IPlanPPlanService planPPlanService;

    /**
     * 查询预案详情列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlanPPlan planPPlan)
    {
        startPage();
        List<PlanPPlan> list = planPPlanService.selectPlanDPlanList(planPPlan);
        return getDataTable(list);
    }

    /**
     * 导出预案详情列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanPPlan planPPlan)
    {
        List<PlanPPlan> list = planPPlanService.selectPlanDPlanList(planPPlan);
        ExcelUtil<PlanPPlan> util = new ExcelUtil<PlanPPlan>(PlanPPlan.class);
        util.exportExcel(response, list, "预案详情数据");
    }

    /**
     * 获取预案详情详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(planPPlanService.selectPlanDPlanById(id));
    }

    /**
     * 新增预案详情
     */
    @PostMapping
    public AjaxResult add(@RequestBody PlanPPlan planPPlan)
    {
        return toAjax(planPPlanService.insertPlanDPlan(planPPlan));
    }

    /**
     * 修改预案详情
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PlanPPlan planPPlan)
    {
        return toAjax(planPPlanService.updatePlanDPlan(planPPlan));
    }

    /**
     * 删除预案详情
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(planPPlanService.deletePlanDPlanByIds(ids));
    }
}
